package com.ruoyi.web.controller.leftover;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.*;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.ICompanyService;
import com.ruoyi.system.service.ILeftoverInService;
import com.ruoyi.system.service.ILeftoverOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/system/chart")
public class ChartController extends BaseController {

    @Autowired
    private ILeftoverInService leftoverInService;
    @Autowired
    private ILeftoverOutService leftoverOutService;
    @Autowired
    private ICompanyService companyService;

    private String prefix = "leftover/chart";

    @RequestMapping("/floor")
    public String floor() {
        return prefix + "/floor";
    }

    @GetMapping("/inStatistics")
    public String inStatistics() {
        return prefix + "/inStatistics";
    }


    @PostMapping("/inStatistics")
    @ResponseBody
    public AjaxResult inStatistics(LeftoverInDetail leftoverInDetail) {
        List<Series> seriesList = leftoverInService.handelData();
        return AjaxResult.success(seriesList);
    }

    @PostMapping("/inList")
    @ResponseBody
    public TableDataInfo inList(LeftoverInDetail leftoverInDetail)
    {
        startPage();
        List<InChart> list = leftoverInService.selectLeftoverInChart(leftoverInDetail);
        return getDataTable(list);
    }

    @GetMapping("/outStatistics")
    public String outStatistics() {
        return prefix + "/outStatistics";
    }

    @PostMapping("/outStatistics")
    @ResponseBody
    public AjaxResult outStatistics(LeftoverOutDetail leftoverOutDetail) {
        List<Series> seriesList = leftoverOutService.handelData();
        return AjaxResult.success(seriesList);
    }

    @PostMapping("/outList")
    @ResponseBody
    public TableDataInfo outList(LeftoverOutDetail leftoverOutDetail)
    {
        startPage();
        List<OutChart> list = leftoverOutService.selectLeftoverOutChart(leftoverOutDetail);
        return getDataTable(list);
    }

    @GetMapping("/stockStatistics")
    public String stockStatistics() {
        return prefix + "/stockStatistics";
    }

    @PostMapping("/stockStatistics")
    @ResponseBody
    public AjaxResult stockStatisticsPost() {
        List<Stock> seriesList = companyService.handleData();
        return AjaxResult.success(seriesList);
    }

    @PostMapping("/stockList")
    @ResponseBody
    public TableDataInfo stockList(LeftoverOutDetail leftoverOutDetail)
    {
        startPage();
        List<Stock> seriesList = companyService.handleData();
        return getDataTable(seriesList);
    }

    @GetMapping("/notInStatistics")
    public String notInStatistics() {
        return prefix + "/notInStatistics";
    }


    @PostMapping("/notInStatistics")
    @ResponseBody
    public AjaxResult notInStatistics(LeftoverInDetail leftoverInDetail) {
        List<Series> seriesList = leftoverInService.handelData1();
        return AjaxResult.success(seriesList);
    }

    @PostMapping("/notInList")
    @ResponseBody
    public TableDataInfo notInList(LeftoverInDetail leftoverInDetail)
    {
        startPage();
        List<InChart> list = leftoverInService.selectLeftoverInChart(leftoverInDetail);
        return getDataTable(list);
    }
}
